<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>#MaxThreadsBuffer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#MaxThreadsBuffer</h1>

<p>Causes some or all <a href="../Hotkeys.htm">hotkeys</a> to buffer rather than ignore keypresses when their <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a> limit has been reached.</p>

<pre class="Syntax">#MaxThreadsBuffer On|Off</pre>
<h3>Parameters</h3>
<dl>

  <dt>On|Off</dt>
  <dd><p><strong>On</strong>: All hotkey subroutines between here and the next <code>#MaxThreadsBuffer ON</code> directive will buffer rather than ignore presses of their hotkeys whenever their subroutines are at their <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a> limit.</p>
    <p><strong>Off</strong>: This is the default behavior. A hotkey press will be ignored whenever that hotkey is already running its maximum number of threads (usually 1, but this can be changed with <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a>).</p></dd>

</dl>

<h3>Remarks</h3>
<p>This directive is rarely used because this type of buffering, which is OFF by default, usually does more harm than good. For example, if you accidentally press a hotkey twice, having this setting ON would cause that hotkey's subroutine to automatically run a second time if its first <a href="../misc/Threads.htm">thread</a> takes less than 1 second to finish (this type of buffer expires after 1 second, by design). Note that AutoHotkey  buffers hotkeys in several other ways (such as <code><a href="Thread.htm">Thread Interrupt</a></code> and <code><a href="Critical.htm">Critical</a></code>). It's just that this particular way can be detrimental, thus it is OFF by default.</p>
<p>The main use for this directive is to increase the responsiveness of the keyboard's auto-repeat feature. For example, when you hold down a hotkey whose <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a> setting is 1 (the default), incoming keypresses  are ignored if that hotkey subroutine is already running. Thus, when the subroutine finishes, it must wait for the next auto-repeat keypress to come in, which might take 50ms or more due to being caught in between keystrokes of the auto-repeat cycle. This 50ms delay can be avoided by enabling this directive for any hotkey that needs the best possible response time while it is being auto-repeated.</p>
<p>As with all # directives, this one should not be positioned in the script as though it were a command (i.e. it is not necessary to have it contained within a subroutine). Instead, position it immediately before the first hotkey label you wish to have affected by it.</p>
<h3>Related</h3>
<p><a href="_MaxThreads.htm">#MaxThreads</a>, <a href="_MaxThreadsPerHotkey.htm">#MaxThreadsPerHotkey</a>, <a href="Critical.htm">Critical</a>, <a href="Thread.htm">Thread (command)</a>, <a href="../misc/Threads.htm">Threads</a>, <a href="Hotkey.htm">Hotkey</a>, <a href="_MaxHotkeysPerInterval.htm">#MaxHotkeysPerInterval</a>, <a href="_HotkeyInterval.htm">#HotkeyInterval</a>, <a href="ListHotkeys.htm">ListHotkeys</a></p>
<h3>Example</h3>
<pre class="NoIndent">#MaxThreadsBuffer on
#x::MsgBox, This hotkey will use this type of buffering.
#y::MsgBox, And this one too.
#MaxThreadsBuffer off
#z::MsgBox, But not this one.</pre>

</body>
</html>
